package com.molichuxing.job;

import com.molichuxing.service.InvoiceJobService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@JobHandler(value = "invoiceExpireHandler")
@Component
public class InvoiceExpireHandler extends IJobHandler {
    private static final Logger logger = LoggerFactory.getLogger(InvoiceExpireHandler.class);

    @Resource
    private InvoiceJobService invoiceJobService;

    public InvoiceExpireHandler() {
        super();
    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public void destroy() {
        super.destroy();
    }

    @Override
    public ReturnT<String> execute(String param) throws Exception {
        ReturnT<String> returnT = ReturnT.SUCCESS;
        logger.info("==============发票有效期定时任务start================");
        boolean result = invoiceJobService.modifyInvoiceStatus();
        if (!result) {
            returnT = ReturnT.FAIL;
        }
        logger.info("==============发票有效期定时任务end================");
        returnT.setContent("发票有效期定时任务结果result：" + result);
        return returnT;
    }


}
